package com.tarena.lbs.common.basic.converter;

import com.tarena.lbs.pojo.basic.bo.DictBO;
import com.tarena.lbs.pojo.basic.dos.DictDO;
import com.tarena.lbs.pojo.basic.param.DictParam;
import com.tarena.lbs.pojo.basic.vo.DictVO;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

@Component
public class DictConverter {

    public DictVO bo2vo(DictBO bo){
        if (null == bo){
            return null;
        }
        DictVO dictVO = new DictVO();
        BeanUtils.copyProperties(bo,dictVO);
        return dictVO;
    }

    public DictDO param2DO(DictParam param){
        if (null == param){
            return null;
        }
        DictDO dictDO = new DictDO();
        BeanUtils.copyProperties(param,dictDO);
        return dictDO;
    }

    public DictBO do2bo(DictDO dictDO) {
        if (null == dictDO){
            return null;
        }
        DictBO dictBO = new DictBO();
        BeanUtils.copyProperties(dictDO,dictBO);
        return dictBO;
    }


    public List<DictBO> doList2boList(List<DictDO> doList ){
        List<DictBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        for (DictDO dictDO : doList) {
            DictBO dictBO = new DictBO();
            BeanUtils.copyProperties(dictDO,dictBO);
            boList.add(dictBO);
        }
        return boList;
    }

//    public List<BusinessVO> boListvoList(List<BusinessBO> boList ){
//        BusinessVO businessVO = new BusinessVO();
//        List<BusinessVO> businessVOS = new ArrayList<>();
//        for (BusinessBO businessBO : boList) {
//            BeanUtils.copyProperties(businessBO,businessVO);
//            businessVOS.add(businessVO);
//        }
//        return businessVOS;
//    }

}
